<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>songs</title>
    <link rel="stylesheet" href="/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="/static/css/content/admin.css">
    <script src="/static/js/jquery.min.js"></script>
    <script src="/static/js/bootstrap.min.js"></script>
    <script src="/static/js/vue-min.js"></script>
</head>
<body>
<nav class="navbar navbar-expand-lg navbar-dark bg-dark">
    <a class="navbar-brand" href="/">首页</a>
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <div class="collapse navbar-collapse" id="navbarSupportedContent">
        <ul class="navbar-nav mr-auto">
            <li class="nav-item active">
                <a class="nav-link" href="#">后台管理 <span class="sr-only">(current)</span></a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="/category/page">分类歌曲</a>
            </li>
            <li class="nav-item dropdown">
                <a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown"
                   aria-haspopup="true" aria-expanded="false">
                    最近浏览
                </a>
                <div class="dropdown-menu" aria-labelledby="navbarDropdown">
                    <a class="dropdown-item" href="#">Action</a>
                    <a class="dropdown-item" href="#">Another action</a>
                    <div class="dropdown-divider"></div>
                    <a class="dropdown-item" href="#">Something else here</a>
                </div>
            </li>
        </ul>
    </div>
</nav>
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <ul class="nav nav-tabs nav-fill" id="myTab" role="tablist">
                <li class="nav-item">
                    <a class="nav-link active" id="user-tab" data-toggle="tab" href="#user" role="tab"
                       aria-controls="user" aria-selected="true">用户管理</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" id="songs-tab" data-toggle="tab" href="#songs" role="tab" aria-controls="songs"
                       aria-selected="false">歌曲管理</a>
                </li>
            </ul>
            <div class="tab-content" id="myTabContent">
                <!-- user tab -->
                <div class="tab-pane fade show active" id="user" role="tabpanel" aria-labelledby="user-tab">
                    <table class="table table-striped">
                        <thead>
                        <tr>
                            <th scope="col" v-for="title in titles">{{title}}</th>
                        </tr>
                        </thead>
                        <tbody>
                        <tr v-for="(user,index) in users">
                            <th scope="row">{{index+1}}</th>
                            <td>{{user.number}}</td>
                            <td><a type="button" class="btn btn-warning" data-toggle="modal" data-target="#updateRanks"
                                   @click="updateWebUserRank(user.pk,user.rank)">{{user.rank}}
                            </a>
                            </td>
                            <td><a type="button" class="btn btn-warning" data-toggle="modal" data-target="#updateMarks"
                                   @click="updateWebUserMark(user.pk,user.points)">{{user.points}}
                            </a>
                            </td>
                            <td>
                                <a type="button" class="btn btn-danger" data-toggle="modal"
                                   data-target="#deleteUser">X</a>
                            </td>
                        </tr>
                        </tbody>
                    </table>
                    <div class="modal fade" id="deleteUser" tabindex="-1" role="dialog"
                         aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                        <div class="modal-dialog modal-dialog-centered" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" id="sure">确认</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    确定要删除？
                                </div>
                                <div class="modal-footer">
                                    <a type="button" class="btn btn-secondary" data-dismiss="modal">否</a>
                                    <a type="button" class="btn btn-primary">是</a>
                                </div>
                            </div>
                        </div>
                    </div>
                    <hr>
                    <div class="user-search">
                        <div class="form-group">
                            <label for="">查询用户</label>
                            <input type="text" id="username" class="form-control">
                        </div>
                        <a class="btn btn-primary">查询</a>

                        <div id="search-result">
                            <h3>查询结果</h3>
                        </div>
                    </div>

                    <!-- update marks  -->
                    <div class="modal fade" id="updateMarks" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel"
                         aria-hidden="true">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" id="updateMarkHead">更新积分</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    <div>
                                        <div class="form-class">
                                            <label for="new-marks1">积分</label>
                                            <input type="text" name="mark" id="new-marks1" class="form-control" v-model="selectedName">
                                            <input type="hidden" name="id" id="userId">
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                                    <button type="button" class="btn btn-primary" @click="updateMark">提交</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- update rank -->
                    <div class="modal fade" id="updateRanks" tabindex="-1" role="dialog"aria-labelledby="exampleModalLabel" aria-hidden="true">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" id="exampleModalLabel">更新等级</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    <div>
                                        <div class="form-class">
                                            <label for="new-marks">等级</label>
                                            <input type="text" name="mark" id="new-marks" class="form-control" v-model="selectedName">
                                            <input type="hidden" name="id" id="id">
                                        </div>
                                    </div>
                                </div>
                                <div class="modal-footer">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                                    <button type="button" class="btn btn-primary" @click="updateRank">提交</button>
                                </div>
                            </div>
                        </div>
                    </div>


                </div>
                <!-- song tab -->
                <div class="tab-pane fade" id="songs" role="tabpanel" aria-labelledby=" songs-tab">
                    <div class="col-md-12">
                        <h2>歌曲信息及其操作</h2>
                        <button type="button" class="btn btn-primary btn-block" data-toggle="modal"
                                data-target="#uploadSongModal" data-whatever="@mdo">添加歌曲
                        </button>
                    </div>
                    <!-- model here-->
                    <!-- add new song -->
                    <div class="modal fade" id="uploadSongModal" tabindex="-1" role="dialog"
                         aria-labelledby="addSongHead" aria-hidden="true">
                        <div class="modal-dialog" role="document">
                            <div class="modal-content">
                                <div class="modal-header">
                                    <h5 class="modal-title" id="addSongHead">添加新的歌曲</h5>
                                    <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                        <span aria-hidden="true">&times;</span>
                                    </button>
                                </div>
                                <div class="modal-body">
                                    <form enctype="multipart/form-data">
                                        <div class="form-group">
                                            <label for="recipient-name" class="col-form-label">标题:</label>
                                            <input type="text" class="form-control" v-model="name1" id="recipient-name"
                                                   placeholder="默认为文件名">
                                        </div>
                                        <div class="form-group">
                                            <label for="singer">歌手</label>
                                            <input type="text" class="form-control" placeholder="默认"  name="singer" v-model="singer1"
                                                   id="singer">
                                        </div>
                                        <div class="form-group">
                                            <label for="lang">语言</label>
                                            <input type="text" class="form-control" v-model="language1" name="lang"
                                                   id="lang">
                                        </div>
                                        <div class="song-style">
                                            <label for="s-style1">风格</label>
                                            <input type="text" class="form-control" v-model="style1" name="style"
                                                   id="s-style1">
                                        </div>
                                        <div class="form-group">
                                            <label for="rylic-text" class="col-form-label">歌词:</label>
                                            <textarea class="form-control" id="rylic-text" v-model="lyric1"
                                                      name="rylic"></textarea>
                                        </div>
                                        <div class="form-group">
                                            <label for="songfile1">歌曲文件</label>
                                            <input type="file" id="songFile1" class="form-control" name="songfile"
                                                   accept="audio/*">
                                        </div>
                                        <div class="form-group">
                                            <label for="imageFile1">封面文件</label>
                                            <input type="file" id="imageFile1" class="form-control" name="imageFile"
                                                   accept="image/*">
                                        </div>
                                        <div class="form-group">
                                            <label for="">权限等级</label>
                                            <select name="rank" id="rankSelect" v-model="rank1" class="form-control">
                                                <option value="0">普通</option>
                                                <option value="1">vip 1</option>
                                                <option value="2">vip 2</option>
                                            </select>
                                        </div>
                                    </form>
                                </div>
                                <div class="modal-footer">
                                    <h6 v-if="uploading" class="text-success">上传中...</h6>
                                    <hr v-if="uploading">
                                    <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                                    <button type="button" class="btn btn-primary" @click="uploadSong">提交</button>
                                </div>
                            </div>
                        </div>
                    </div>
                    <!-- model end -->

                    <!-- model here-->
                    <!-- update song -->

                    <!-- model end -->
                    <div class="col-md-12" id="songsTableObject">
                        <table class="table table-striped">
                            <thead>
                            <tr>
                                <th scope="col" v-for="title in titles">{{title}}</th>
                            </tr>
                            </thead>
                            <tbody>
                            <tr v-for="(song,index) in songs">
                                <th scope="row">{{index+1}}</th>
                                <td>{{song.name}}</td>
                                <td>{{song.singer}}</td>
                                <td>
                                    <a type="button" class="btn btn-danger" data-toggle="modal"
                                       data-target="#sureDelete" @click="updateDeleteModal(song.pk,song.name)">X</a>
                                </td>
                                <td>
                                    <a type="button" class="btn btn-primary" data-toggle="modal"
                                       data-target="#updateSongModel" data-whatever="@mdo" style="float:right"
                                       @click="updateSongInformation(song.pk,song.name,song.singer,song.lyric,song.style,song.language)"
                                    >#</a>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                        <!-- 删除 Modal -->
                        <div class="modal fade" id="sureDelete" tabindex="-1" role="dialog"
                             aria-labelledby="exampleModalCenterTitle" aria-hidden="true">
                            <div class="modal-dialog modal-dialog-centered" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="exampleModalLongTitle">确认</h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                        确定要删除:{{selectedName}}？
                                    </div>
                                    <div class="modal-footer">
                                        <a type="button" class="btn btn-secondary" data-dismiss="modal">否</a>
                                        <a type="button" class="btn btn-danger" :href="'/song/del/'+selectedPK">是</a>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <div class="modal fade" id="updateSongModel" tabindex="-1" role="dialog"
                             aria-labelledby="exampleModalLabel" aria-hidden="true">
                            <div class="modal-dialog" role="document">
                                <div class="modal-content">
                                    <div class="modal-header">
                                        <h5 class="modal-title" id="updateSongHead">更新歌曲</h5>
                                        <button type="button" class="close" data-dismiss="modal" aria-label="Close">
                                            <span aria-hidden="true">&times;</span>
                                        </button>
                                    </div>
                                    <div class="modal-body">
                                        <div id="updateSongForm">
                                            <div class="form-group">
                                                <label for="recipient-name1" class="col-form-label">歌曲名:</label>
                                                <input type="text" class="form-control" id="recipient-name1"  v-model="selectedName">
                                            </div>
                                            <div class="form-group">
                                                <label for="singer1">歌手</label>
                                                <input type="text" class="form-control" name="singer" id="singer1" v-model="selecteSinger">
                                            </div>
                                            <div class="form-group">
                                                <label for="lang1">语言</label>
                                                <input type="text" class="form-control" name="lang" id="lang1" v-model="selecteLanguage">
                                            </div>
                                            <div class="song-style">
                                                <label for="s-style">风格</label>
                                                <input type="text" class="form-control" name="style" id="s-style" v-model="selecteStyle">
                                            </div>
                                            <div class="form-group">
                                                <label for="rylic-text1" class="col-form-label">歌词:</label>
                                                <textarea class="form-control" id="rylic-text1" name="rylic"  v-model="selecteLyric"></textarea>
                                            </div>
                                            <div class="form-group">
                                                <label for="songfile">歌曲文件</label>
                                                <input type="file" id="songFile" class="form-control" name="songfile">
                                            </div>
                                            <div class="form-group">
                                                <label for="imageFile">封面文件</label>
                                                <input type="file" id="imageFile" class="form-control" name="imageFile">
                                            </div>
                                            <div class="form-group">
                                                <label for="">权限等级</label>
                                                <select name="rank" id="" class="form-control">
                                                    <option value="0">普通</option>
                                                    <option value="1">vip 1</option>
                                                    <option value="2">vip 2</option>
                                                </select>
                                            </div>
                                        </div>
                                    </div>
                                    <div class="modal-footer">
                                        <button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>
                                        <button type="button" class="btn btn-primary">提交</button>
                                    </div>
                                </div>
                            </div>
                        </div>
                        <hr>
                        <nav aria-label="Page navigation example">
                            <ul class="pagination">
                                <li class="page-item">
                                    <a class="page-link" href="#" aria-label="Previous" @click="prePage">
                                        <span aria-hidden="true">&laquo;</span>
                                        <span class="sr-only">Previous</span>
                                    </a>
                                </li>
                                <li v-for="page in pageSize"
                                    v-if="(page-currentPage) == 0"
                                    class="page-item active">
                                    <a class="page-link">{{page}}</a>
                                </li>
                                <li v-for="page in pageSize"
                                    v-if="(page - currentPage) > 0 && (page-currentPage) < 6"
                                    class="page-item">
                                    <a class="page-link" @click="updateSongs(page)">{{page}}</a>
                                </li>
                                <li class="page-item" v-if="(pageSize-currentPage >= 6)">
                                    <a class="page-link">..</a>
                                </li>
                                <li class="page-item">
                                    <a class="page-link" href="#" aria-label="Next" @click="nextPage">
                                        <span aria-hidden="true">&raquo;</span>
                                        <span class="sr-only">Next</span>
                                    </a>
                                </li>
                            </ul>
                        </nav>
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
<script src="/static/js/content/admin.js"></script>

</body>
</html>